package com.pai4j.pgc.service.message.builder;
import com.pai4j.common.constants.MessageConstants;
import com.pai4j.common.constants.WebConstant;
import com.pai4j.common.enums.community.ResourceTypeEnum;
import com.pai4j.domain.vo.dto.SystemMessageDTO;


import java.util.Date;

/**
 *
 *
 * @author: CYM-pai
 * @date: 2025/10/27 20:45
 **/
public class SystemMessageBuilder extends AbstractMessageBuilder {

    /**
     * 构建基础系统消息
     *
     * @param type
     * @param toUserId
     * @param content
     * @return
     */
    public SystemMessageDTO build(MessageConstants.TypeEnum type,
                                  String toUserId,
                                  String content) {
        SystemMessageDTO message = new SystemMessageDTO();
        message.setCategory(getMessageCategory());
        message.setType(type.getType());
        message.setFromUserId(WebConstant.SYSTEM_USER_ID);
        message.setToUserId(toUserId);
        message.setContent(content);
        message.setCreateDate(new Date());
        return message;
    }

    /***
     * 构建有活动类系统消息
     * @param type
     * @param toUserId
     * @param content
     * @param activityName
     * @param activityUrl
     * @return
     */
    public SystemMessageDTO buildActivityMessage(MessageConstants.TypeEnum type,
                                                 String toUserId,
                                                 String content,
                                                 String activityName,
                                                 String activityUrl) {
        SystemMessageDTO message = this.build(type, toUserId, content);
        message.setActivityName(activityName);
        message.setActivityUrl(activityUrl);
        return message;
    }

    /***
     * 构建涉及资源的消息
     * @param type
     * @param toUserId
     * @param content
     * @param resourceType
     * @param resourceId
     * @return
     */
    public SystemMessageDTO buildResourceMessage(MessageConstants.TypeEnum type,
                                                 String toUserId,
                                                 String content,
                                                 ResourceTypeEnum resourceType,
                                                 String resourceId) {
        SystemMessageDTO message = this.build(type, toUserId, content);
        message.setResourceType(resourceType.getType());
        message.setResourceId(resourceId);
        return message;
    }

    @Override
    protected String getMessageCategory() {
        return MessageConstants.CategoryEnum.SYSTEM.getCategory();
    }
}
